package com.fitz.core.config;

import com.fitz.core.context.FilterRegistry;
import com.fitz.core.filter.AbstractFilter;

import javax.annotation.PostConstruct;
import java.util.Map;

/**
 * @author gousl01
 * @date 2021/3/15 17:34
 * @desc
 */
public class FitzGatewayInitializer {

    private final Map<String, AbstractFilter> filters;

    public FitzGatewayInitializer(Map<String, AbstractFilter> filters) {
        this.filters = filters;
    }

    /**
     * 将所有的继承自AbstractFilter的过滤器 放入容器中
     */
    @PostConstruct
    public void init(){
        for (Map.Entry<String,AbstractFilter> entry : filters.entrySet()){
            FilterRegistry.getInstance().put(entry.getKey(), entry.getValue());
        }
    }
}
